package com.example.mypplication

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.os.Message
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import com.example.mypplication.aartest.AARTestActivity
import com.example.mypplication.aicoze.CozeAiActivity
import com.example.mypplication.component.Component2Activity
import com.example.mypplication.component.Component3Activity
import com.example.mypplication.component.Component4Activity
import com.example.mypplication.component.ComponentActivity
import com.example.mypplication.databinding.ActivityMainBinding
import com.example.mypplication.dispatchersio.DispatchersIOActivity
import com.example.mypplication.doubleslide.BiDemoActivity
import com.example.mypplication.expendlist.ExpendListActivity
import com.example.mypplication.expendlist.FlexboxExpandActivity
import com.example.mypplication.multiscreen.MutilScreenActivity
import com.example.mypplication.opengl.OpenGLActivity
import com.example.mypplication.sortlist.SortListActivity
import com.example.mypplication.sortlist.newsortlist.ContactListActivity
import com.example.mypplication.sortlist.newsortlist.NewSortListActivity

class MainActivity : AppCompatActivity() {
    private lateinit var mainBinding:ActivityMainBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        WindowCompat.setDecorFitsSystemWindows(window, true)
        mainBinding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(mainBinding.root)

        initDetail()

        initHandler()

        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

    }

    private fun initHandler() {
        val mObject = Handler.Callback {
            true
        }
        val mHandler = Handler(Looper.getMainLooper(), mObject)
        mHandler.sendMessage(Message.obtain())
    }

    private fun initDetail() {
        mainBinding.btnGoAartest.setOnClickListener {
            startActivity(Intent(this@MainActivity, AARTestActivity::class.java).apply {

            })
        }
        mainBinding.btnGoDispatchersIOActivity.setOnClickListener {
            startActivity(Intent(this@MainActivity, DispatchersIOActivity::class.java).apply {

            })
        }
        mainBinding.btnGoGlideTestActivity.setOnClickListener {
            startActivity(Intent(this@MainActivity, GlideTestActivity::class.java).apply {

            })
        }
        mainBinding.btnGoMutilScreenActivity.setOnClickListener {
            startActivity(Intent(this@MainActivity, MutilScreenActivity::class.java).apply {

            })
        }
        mainBinding.btnGoOpenGLActivity.setOnClickListener {
            startActivity(Intent(this@MainActivity, OpenGLActivity::class.java).apply {

            })
        }

        mainBinding.btnGoComponentActivity.setOnClickListener {
            startActivity(Intent(this@MainActivity, ComponentActivity::class.java).apply {

            })
        }
        mainBinding.btnGoComponent2Activity.setOnClickListener {
            startActivity(Intent(this@MainActivity, Component2Activity::class.java).apply {

            })
        }
        mainBinding.btnGoComponent3Activity.setOnClickListener {
            startActivity(Intent(this@MainActivity, Component3Activity::class.java).apply {

            })
        }
        mainBinding.btnGoComponent4Activity.setOnClickListener {
            startActivity(Intent(this@MainActivity, Component4Activity::class.java).apply {

            })
        }
        mainBinding.btnGoSortListActivity.setOnClickListener {
            startActivity(Intent(this@MainActivity, SortListActivity::class.java).apply {

            })
        }
        mainBinding.btnGoNewSortListActivity.setOnClickListener {
            startActivity(Intent(this@MainActivity, NewSortListActivity::class.java).apply {

            })
        }
        mainBinding.btnGoContactListActivity.setOnClickListener {
            startActivity(Intent(this@MainActivity, ContactListActivity::class.java).apply {

            })
        }
        mainBinding.btnGoExpendListActivity.setOnClickListener {
            startActivity(Intent(this@MainActivity, ExpendListActivity::class.java).apply {

            })
        }
        mainBinding.btnGoBiDemoActivity.setOnClickListener {
            startActivity(Intent(this@MainActivity, BiDemoActivity::class.java).apply {

            })
        }
        mainBinding.btnGoFlexboxExpandActivity.setOnClickListener {
            startActivity(Intent(this@MainActivity, FlexboxExpandActivity::class.java).apply {

            })
        }
        mainBinding.btnGoCozeAiActivity.setOnClickListener {
            startActivity(Intent(this@MainActivity, CozeAiActivity::class.java).apply {

            })
        }

    }
}